package com.dwxt.information.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.information.entity.Information;
import com.dwxt.information.service.InformationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Slf4j
@RestController
public class InformationController {
    @Autowired
    private InformationService informationService;


    @GetMapping("/information/reply")
    public BaseResult msgReply(Information information) throws IOException {
        //log.info("websocket reply: {}", msg);
        informationService.insert(information);
        informationService.sendMsg(information);
        return BaseResult.ok();
    }

    @RequestMapping("/information/close")
    public BaseResult close(Information information){
        informationService.close(information);
        return BaseResult.ok();
    }

}
